<!--
 * @Author: fanyaqing
 * @Date: 2021-08-09 15:02:01
 * @LastEditTime: 2021-08-11 14:35:27
 * @LastEditors: fanyaqing
 * @Description: 
 * @FilePath: \supermall\src\views\detail\childComponents\detailNavBar.vue
-->
<template>
  <div>
    <nav-bar>
      <div slot="left" class="back" @click="backClick">
        <img  src="~assets/img/common/back.svg">
      </div>
      <div slot="center" class="titles">
        <span :class="{active:currentIndex==index}" v-for="(item, index) in titles" :key="index" @click="itemClick(index)">{{item}}</span>
      </div>
    </nav-bar>
  </div>
</template>
<script>
import NavBar from 'components/common/navbar/NavBar'

export default {
  components:{
    NavBar
  },
  data() {
    return {
      titles:['商品','参数','评论','推荐'],
      currentIndex:0
    }
  },
  methods:{
    itemClick(index){
      this.currentIndex=index;
      this.$emit('titleClick',index)
    },
    backClick(){
      this.$router.back();
    }
  }
}
</script>
<style scoped>
  .back img{
    vertical-align: middle;
  }
  .titles{
    display: flex;
  }
  .titles span{
    flex: 1;
    font-size: 14px;
  }
  .active{
    color: var(--color-high-text);
  }
</style>